/* 租户管理 */
import request from '@/utils/request'

const basePath = '/jpower-system'

/**
 * @description:
 * @param {type}
 * @return {type}
 */
export function list(params = {}) {
  return request({
    url: basePath + '/core/tenant/list',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

export function add(params = {}) {
  return request({
    url: basePath + '/core/tenant/add',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

export function removeItem(ids) {
  return request({
    url: basePath + '/core/tenant/delete',
    method: 'delete',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params: { ids }
  })
}

export function updateItem(params) {
  return request({
    url: basePath + '/core/tenant/update',
    method: 'put',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

/**
 * @description: 租户授权配置
 * @param {*} params
 * @return {*}
 */
export function useSetting(params) {
  return request({
    url: basePath + '/core/tenant/setting',
    method: 'put',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

export function getTenant(tenantName) {
  return request({
    url: basePath + '/core/tenant/selectors',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params: { tenantName }
  })
}
